package com.test.service.impl;

import com.test.mapper.FoodTypeMapper;
import com.test.pojo.FoodType;
import com.test.service.FoodTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author suxuexia
 * @create 2019-09-24 18:26
 */
@Service
public class FoodTypeServiceImpl implements FoodTypeService {
    @Resource
    private FoodTypeMapper foodTypeMapper;

    @Override
    public List<FoodType> getAllFoodType() {
        return foodTypeMapper.getAllFoodType();
    }

    @Override
    public int updateFoodType(FoodType foodType) {
        return foodTypeMapper.updateFoodType(foodType);
    }

    @Override
    public int deleteFoodType(int typeId) {
        int num = 0;
        try {
            num = foodTypeMapper.deleteFoodType(typeId);
        }catch (Exception e){
            // 数据库异常
            num = -1;
        }
        return num;
    }

    @Override
    public int addFoodType(FoodType foodType) {
        return foodTypeMapper.addFoodType(foodType);
    }

    @Override
    public List<FoodType> serachFoodType(String typeName) {
        return foodTypeMapper.serachFoodType(typeName);
    }

    @Override
    public FoodType getFoodTypeByID(int typeId) {
        return foodTypeMapper.getFoodTypeByID(typeId);
    }
}
